package lt.inkredibl.iit.action;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;

import lt.inkredibl.iit.ImgComponent;

@SuppressWarnings("serial")
public class ActSetZoom
	extends AbstractAction
{
	private ImgComponent _ic;
	private int _zoom;

	protected ActSetZoom(ImgComponent ic, int zoom)
	{
		_ic = ic;
		_zoom = (zoom == 0 ? 1 : zoom);
		
		putValue(Action.NAME, "Zoom "+(_zoom > 0 ? _zoom : "1/"+(-_zoom)));
		//putValue(Action.MNEMONIC_KEY, KeyEvent.VK_O);
	}
	
	public static ActSetZoom inst(ImgComponent ic, int zoom)
	{
		return new ActSetZoom(ic, zoom);
	}

	public void actionPerformed(ActionEvent e)
	{
		_ic.setZoom(_zoom);
	}

}
